package com.jo.bean;

import lombok.Data;

import java.util.ArrayList;
import java.util.List;

/**
 *
 * bean定义
 * @author Jo
 * @date 2017/8/22
 */
@Data
public class BeanDefinition {
    protected String beanId;

    protected String beanName;

    protected List<Property> properties = new ArrayList<>();

    protected Class clazz;

    protected List<Property> constructorArgs;

    protected Boolean singleton = Boolean.TRUE;

    public BeanDefinition(String beanId, String beanName, Class clazz) {
        this.beanId = beanId;
        this.beanName = beanName;
        this.clazz = clazz;
    }

    public BeanDefinition() {
    }

    public Property getProperty(String propertyName){
        for (Property property : this.properties) {
            if (property.getName().equals(propertyName)){
                return property;
            }
        }

        return null;
    }
}
